home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 10.5 KB | 331 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWAplEvt.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWAPLEVT_H
- #include "FWAplEvt.h"
- #endif
-
- #ifndef FWDSCOPR_H
- #include "FWDscOpr.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWSCPTBL_H
- #include "FWScptbl.h"
- #endif
-
- #ifndef FWSESION_H
- #include "FWSesion.h"
- #endif
-
- // ----- Macintosh Includes -----
-
- #ifndef __ASREGISTRY__
- #include <ASRegistry.h>
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODAppleEvent_xh
- #include <ODAplEvt.xh>
- #endif
-
- #ifndef SOM_ODMessageInterface_xh
- #include <MssgIntf.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwsemevt1
- #endif
-
- FW_DEFINE_AUTO(FW_CAppleEvent)
-
- //========================================================================================
- // CLASS FW_CAppleEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::FW_CAppleEvent
- //----------------------------------------------------------------------------------------
-
- FW_CAppleEvent::FW_CAppleEvent(ODAppleEvent* odAppleEvent) :
- FW_CDesc(odAppleEvent)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::FW_CAppleEvent
- //----------------------------------------------------------------------------------------
-
- FW_CAppleEvent::FW_CAppleEvent(const FW_CPart* fromPart,
- ODEventClass eventClass,
- ODEventID eventID,
- const FW_CDesc& addressDesc) :
- FW_CDesc()
- {
- FW_UNUSED(fromPart);
-
- FW_SOMEnvironment ev;
- ODMessageInterface* msgInt = FW_CSession::GetMessageInterface(ev);
- fReturnID = msgInt->CreateEvent(ev, eventClass, eventID, addressDesc, 0, *this);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::~FW_CAppleEvent
- //----------------------------------------------------------------------------------------
-
- FW_CAppleEvent::~FW_CAppleEvent()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::HasAttribute
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CAppleEvent::HasAttribute(ODDescType key) const
- {
- FW_CDesc attribute;
- return (::AEGetAttributeDesc(*this, key, typeWildCard, attribute) == FW_xNoError);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::GetAttributeByPtr
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::GetAttributeByPtr(ODDescType dataType,
- void* dataPtr,
- Size* dataSize,
- Size maxSize,
- AEKeyword key) const
- {
- Size actualSize;
- ODDescType actualType;
-
- FW_FailOnError(::AEGetAttributePtr(*this, key, dataType, &actualType, dataPtr, maxSize, &actualSize));
-
- if (dataType != typeWildCard && actualType != dataType)
- FW_Failure(errAECoercionFail);
-
- if (dataSize)
- *dataSize = actualSize;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::PutAttributeByPtr
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::PutAttributeByPtr(ODDescType dataType,
- const void* dataPtr,
- Size dataSize,
- AEKeyword key)
- {
- FW_ASSERT(!IsNullDescriptor());
- FW_FailOnError(::AEPutAttributePtr(*this, key, dataType, dataPtr, dataSize));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::GetAttributeByDesc
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::GetAttributeByDesc(AEKeyword key,
- FW_CDesc& desc,
- ODDescType desiredType) const
- {
- FW_FailOnError(::AEGetAttributeDesc(*this, key, desiredType, desc));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::PutAttributeByDesc
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::PutAttributeByDesc(AEKeyword key, const FW_CDesc& desc)
- {
- FW_ASSERT(!IsNullDescriptor());
- FW_FailOnError(::AEPutAttributeDesc(*this, key, desc));
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::GetSubject
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::GetSubject(FW_CDesc& subjectDesc) const
- {
- GetAttributeByDesc(keySubjectAttr, subjectDesc);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::SetSubject
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::SetSubject(const FW_CDesc& subjectDesc)
- {
- FW_ASSERT(!IsNullDescriptor());
- PutAttributeByDesc(keySubjectAttr, subjectDesc);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::GetTarget
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::GetTarget(FW_CDesc& targetDesc) const
- {
- GetAttributeByDesc(keyAETarget, targetDesc);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::SetTarget
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::SetTarget(const FW_CDesc& targetDesc)
- {
- PutAttributeByDesc(keyAETarget, targetDesc);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::GetEventClass
- //----------------------------------------------------------------------------------------
-
- AEKeyword FW_CAppleEvent::GetEventClass() const
- {
- AEKeyword eventClass;
-
- GetAttributeByPtr(typeType, &eventClass, NULL, sizeof(eventClass), keyEventClassAttr);
- return eventClass;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::SetEventClass
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::SetEventClass(AEKeyword eventClass)
- {
- FW_ASSERT(!IsNullDescriptor());
- PutAttributeByPtr(typeType, &eventClass, sizeof(eventClass), keyEventClassAttr);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::GetEventID
- //----------------------------------------------------------------------------------------
-
- AEKeyword FW_CAppleEvent::GetEventID() const
- {
- AEKeyword eventID;
-
- GetAttributeByPtr(typeType, &eventID, NULL, sizeof(eventID), keyEventIDAttr);
- return eventID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::SetEventID
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::SetEventID(AEKeyword eventID)
- {
- FW_ASSERT(!IsNullDescriptor());
- PutAttributeByPtr(typeType, &eventID, sizeof(eventID), keyEventIDAttr);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::SendToSelf
- //----------------------------------------------------------------------------------------
-
- void FW_CAppleEvent::SendToSelf(Environment* ev,
- FW_CFrame* toFrame,
- FW_CAppleEvent* resultEvent,
- ODSendPriority sendPriority,
- ODULong timeOutInTicks)
- {
- FW_UNUSED(ev);
- FW_UNUSED(toFrame);
- FW_UNUSED(resultEvent);
- FW_UNUSED(sendPriority);
- FW_UNUSED(timeOutInTicks);
- //msgInt->CreatePartAddrDesc(ev, partAddress, part->GetODPart(ev));
-
-
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::operator ODAppleEvent*
- //----------------------------------------------------------------------------------------
-
- FW_CAppleEvent::operator ODAppleEvent*() const
- {
- PrivUpdateODDescIfStale();
- PrivODDescChanged();
- return (ODAppleEvent*)PrivGetODDescPtr();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::operator ODAppleEvent**
- //----------------------------------------------------------------------------------------
-
- FW_CAppleEvent::operator ODAppleEvent**()
- {
- PrivDispose();
- PrivODDescChanged();
- return (ODAppleEvent**)PrivGetODDescHandle();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAppleEvent::PrivCreateODDesc
- //----------------------------------------------------------------------------------------
-
- ODDesc* FW_CAppleEvent::PrivCreateODDesc(Environment* ev) const
- {
- ODAppleEvent* appleEvent = new ODAppleEvent;
- appleEvent->InitODAppleEvent(ev);
-
- return appleEvent;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_MakeSetLocalPropertyEvent : Given a local scriptable object, a property type,
- // and a new value for the property, create a recordable apple event that, when execute,
- // sets the specified property to the new value.
- //
- // This method is present for illustrative purposes only. ODF 1 does not implement
- // factored event handling or recordability.
- //----------------------------------------------------------------------------------------
-
- FW_CAppleEvent* FW_MakeSetLocalPropertyEvent(Environment* ev,
- FW_CPart* part,
- FW_MScriptable* theObject,
- ODDescType whichProperty,
- FW_CDesc& newValue)
- {
- FW_CDesc partAddress;
- ODMessageInterface* msgInt;
- FW_CAppleEvent* setPropertyEvent;
-
- msgInt = FW_CSession::GetMessageInterface(ev);
-
- msgInt->CreatePartAddrDesc(ev, partAddress, part->GetODPart(ev));
-
- setPropertyEvent = FW_NEW(FW_CAppleEvent, (part, kAECoreSuite, kAESetData, partAddress));
-
- FW_CDesc directObject;
- theObject->GetPropertySpecifier(ev, part, whichProperty, directObject);
-
- setPropertyEvent->PutDataByDesc(directObject, keyDirectObject);
- setPropertyEvent->PutDataByDesc(newValue, keyAEData);
-
- return setPropertyEvent;
- }
-